package sto.orz.json.webapp.action;

import sto.orz.html.form.Form;
import sto.orz.html.form.FormFactory;
import sto.orz.json.JSONResponse;

public class FormAction extends BaseJSONAction {

	private static final long	serialVersionUID	= 2938374610910486238L;

	public String todo(String modelName) {
		Class<?> modelClass;
		try {
			modelClass = loadModel(modelName);
		} catch (Exception e1) {
			return message("Request domain model not found!");
		}

		Form form = FormFactory.getForm(modelClass);
		form.setName(modelName);
		// JSONStringFormater formater = new JSONStringFormater(json.toJson());
		// System.out.println(formater.toString());

		JSONResponse response = new JSONResponse(true);
		response.add("form", form);
		json = response;

		return JSON_RESPONSE;
	}
}
